<template>
	<view style="">
		<!-- 最上面的搜索框 -->
		<view style="background-color: white;padding:20rpx;padding-bottom: 0;">
			<u-search inputAlign="center" placeholder="客户信息/车辆信息/司机信息" @search="data=[];form.page=1;getData()" @click="data=[];getData()" v-model="form.text" :showAction="false"></u-search>
		</view>
		<!-- 上面的筛选条件 -->
		<view style="background-color: white;;">
			<view style="">
				<u-dropdown>
					<u-dropdown-item title="全部">
						<view class="slot-content" style="background-color: white;padding: 30rpx;text-align: center;">
							<ordersStateCheckBox @change="changeOrderStateCheckBox" :defaultchecked="[2,3,4,7]"></ordersStateCheckBox>
						</view>
					</u-dropdown-item>
					<u-dropdown-item title="支付状态">
						<view class="slot-content" style="background-color: white;padding: 30rpx;text-align: center;">
							<ordersPayStateCheckBox @change="changeOrderPayStateCheckBox" :defaultchecked="[1,2,3]"></ordersPayStateCheckBox>
						</view>
					</u-dropdown-item>
					<u-dropdown-item title="订单来源">
						<view class="slot-content" style="background-color: white;padding: 30rpx;text-align: center;">
							<ordersSourceCheckBox @change="changeOrderSourceCheckBox" :defaultchecked="[0]"> </ordersSourceCheckBox>
						</view>
					</u-dropdown-item>
					<u-dropdown-item title="排序方式">
						<view class="slot-content" style="background-color: white;padding: 30rpx;text-align: center;">
							<OrderSortCheckBox @change="changeOrderShortCheckBox" @changeSortOrder="(e)=>{form.sort_order=e;data=[];getData()}" :defaultchecked="[1]"></OrderSortCheckBox>
						</view>
					</u-dropdown-item>
				</u-dropdown>
			</view>
		</view>
		<!-- 卡片 -->
		<view style="">
			<view style="padding-left: 30rpx;margin-top: 20rpx;margin-bottom: 10rpx;">共 {{form.total}} 任务，排序方式：
			<text v-if="form.sort_col=='orders_add_date'">录入时间</text>
			<text v-if="form.sort_col=='take_date'">出车时间</text>
			<text v-if="form.sort_col=='return_date'">还车时间</text>
			</view>
			<scroll-view scroll-y style="height: calc(100vh - 240rpx);" @scrolltolower="scrolltolower" :refresher-enabled="true" :refresher-triggered="refresher" @refresherrefresh="refresherpulling">
				<view v-for="(item,idx) in data">
					<orderCard2 :orders="item"></orderCard2> 
				</view>
				
			</scroll-view>

		</view>
	</view>
</template>

<script>
import http from '../../http/http';

	export default {
		comments: {

		},
		data() {
			return {
				refresher:false,
				data:[],
				orders_state_list: [{
					label: '待出车',
					name: 1,
					checked: true
				}, {
					label: '已出车',
					name: 2,
					checked: false,
				}, {
					label: '已还车',
					name: 3,
					checked: false
				}],
				form: {
					query_pay_stateList:[1,2,3],
					query_stateIdList: [2, 3,4,5,6,7],
					page:1,
					limit:20,
					sort_col:'orders_add_date',
					sort_order:'descending',
					total:0,
					text:''
				},
				value: [1],
				defaultchecked: [],
				keyword: 'gjfhg',
				dropdownValues: {
					value1: '',
					value2: '',
					value3: '',
				},
				dropdownOptions: {
					options1: [{
						label: '待出车',
						value: 1
					}, {
						label: '已出车',
						value: 1
					}, {
						label: '已还车',
						value: 1
					}],
					options2: [{
						label: '待出车',
						value: 1
					}],
					options3: [{
						label: '待出车',
						value: 1
					}]
				}
			}
		},
		mounted() {
			this.getData();
			var that = this;
			uni.$on('getOrdersInfo', function(data) {
				console.log("监听到了，啦啦啦");
				that.getData();
			})
		},
		
		methods: {
			refresherpulling(){
				this.form.page=1;
				this.refresher=true;
				this.data=[];
				this.getData();
			},
			scrolltolower(e){
				console.log(e);
				this.form.page++;
				this.getData();
			},
			getData(){
				var that=this;
				that.$http.post('/orders/ListByEntity', that.form, (res) => {
					if (res.data.success) {
						that.data=that.data.concat(res.data.result.list);
						that.form.total=res.data.result.count;
						that.refresher=false;
					} else {
						that.refs.myModal.show('请求失败', res.data.result.message);
					}
				});
			},
			checkboxGroupChange(e) {
				// this.form.page=1;
				// this.form.query_stateIdList = e;
				// this.getData();
			},
			changeOrderStateCheckBox(e) {
				this.form.query_stateIdList=e;
				this.form.page=1;
				this.data=[];
				this.getData();
			},changeOrderSourceCheckBox(e) {
				this.form.orders_source_id=e[0];
				if(this.form.orders_source_id==0){
					this.form.orders_source_id='';
				}
				this.form.page=1;
				this.data=[];
				this.getData();
			},
			changeOrderPayStateCheckBox(e){
				this.form.page=1;
				this.form.query_pay_stateList=e;
				this.data=[];
				this.getData();
			},
			changeOrderShortCheckBox(e){
				var sort_col=['','orders_add_date','take_date','return_date'][e];
				this.form.sort_col=sort_col;
				this.data=[];
				this.getData();
			}
		}
	}
</script>

<style>

</style>